'''
1.类
2.继承
3.多态
4.封装等基本信息
'''
import  logging
from os import pardir
import pdb
logging.basicConfig(level=logging.INFO,filename='log.txt')


# 定义类
class Employee:
    '所有员工的基类'
    age=0 # 类变量
    # 初始化方法
    def __init__(self,name,age):
        print('-------------->init')
        self.name=name
        self.age=age
        self.age+=age
    def displayCount(self):
        print ('total  age %d' % Employee.age)

    def displayEmployee(self):
        print ('name:',self.name,'age:',self.age)
    # 魔术方法-对内在方法的重写
    # 删除命令
    def __del__(self):
        '''
        魔术函数：在没有引用对象得情况下，del 会调用这个函数
        '''
        print('--------------------->del')
        pass
    # 首先执行，为实例对象，开辟一个地址空间
    def __new__(cls,*args,**kwargs):
        print('========>new 申请一个内存地址')
        return object.__new__(cls)
    # 将对象当函数调用，执行的方法
    def __call__(self,name):  
        print('------------->call')
        print('执行对象当函数，传过来的参数是：'+name)
        pass

class EmployeeSon(Employee):
    def __init__(self, name, age):
        super().__init__(name, age)
    pass
    def displayEmployee(self):
        print ('name:',self.name,'age:',self.age)

    @property
    def score(self):
        return self._score
    
    @score.setter
    def score(self,value):
        if not isinstance(value,int):
            print('value is not int!')
        if value<0 or value>100:
            print('value must between 0~100!')
            self._score=value


class EmployeeSis(Employee):
    def __init__(self, name, age,address):
        super().__init__(name,age)
        self._address=address
    # 装饰器，可以保证私有属性私密性，又可以让外部可以修改访问
    @property
    def address(self):
        print(self._address)
    @address.setter
    def address(self,value):
        self._address=value
# 创建实例
tson=EmployeeSon('nameson','13')
tson.displayEmployee()

# properties 属性测试
tsis=EmployeeSis('sister','12','beijing')
tsis.address
tsis.address='上海'
tsis.address
